- if can? current_user, :write_merge_request, @project
  = link_to new_project_merge_request_path(@project), class: "pull-right btn btn-new", title: "New Merge Request" do
    %i.icon-plus
    New Merge Request
%h3.page-title
  Merge Requests
  %span (#{@merge_requests.total_count})
%hr
.row
  .col-md-3
    = render 'shared/project_filter', project_entities_path: project_merge_requests_path(@project)
  .col-md-9
    .mr-filters.append-bottom-10
      .dropdown.inline
        %a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"}
          %i.icon-user
          %span.light assignee:
          - if @assignee.present?
            %strong= @assignee.name
          - elsif params[:assignee_id] == "0"
            Unassigned
          - else
            Any
          %b.caret
        %ul.dropdown-menu
          %li
            = link_to project_filter_path(assignee_id: nil) do
              Any
            = link_to project_filter_path(assignee_id: 0) do
              Unassigned
          - @assignees.sort_by(&:name).each do |user|
            %li
              = link_to project_filter_path(assignee_id: user.id) do
                = image_tag avatar_icon(user.email), class: "avatar s16", alt: ''
                = user.name

      .dropdown.inline.prepend-left-10
        %a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"}
          %i.icon-time
          %span.light milestone:
          - if @milestone.present?
            %strong= @milestone.title
          - elsif params[:milestone_id] == "0"
            None (backlog)
          - else
            Any
          %b.caret
        %ul.dropdown-menu
          %li
            = link_to project_filter_path(milestone_id: nil) do
              Any
            = link_to project_filter_path(milestone_id: 0) do
              None (backlog)
          - project_active_milestones.each do |milestone|
            %li
              = link_to project_filter_path(milestone_id: milestone.id) do
                %strong= milestone.title
                %small.light= milestone.expires_at

      .pull-right
        = render 'shared/sort_dropdown'

    .ui-box
      %ul.well-list.mr-list
        = render @merge_requests
        - if @merge_requests.blank?
          %li
            .nothing-here-block No merge requests to show
    - if @merge_requests.present?
      .pull-right
        %span.cgray.pull-right #{@merge_requests.total_count} merge requests for this filter

      = paginate @merge_requests, theme: "gitlab"

:javascript
  $(merge_requestsPage);
